//
//  ViewController.swift
//  MySqliteDemo
//
//  Created by cyptt on 2022/8/17.
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        
  

    }
    @IBAction func createdb(_ sender: UIButton) {
        print("create")

        
        CHFMDB.shareInstance().createDataBase("chdbtest1.sqlite")
    }
    
    @IBAction func open(_ sender: UIButton) {
        
        CHFMDB.shareInstance().open()
    }
    

    @IBAction func create(_ sender: UIButton) {
      
//        CHSqliteManage.shareInstance().createTable("fmdbtab", paramSql: "name text, age integer, sex text")
     
        CHFMDB.shareInstance().createTable("fmdbtab", paramSql: "name text, age integer, sex text")
    }
    
    @IBAction func insert(_ sender: UIButton) {
        print("insert")
        
        let map:[String:Any] = ["name":"zs","age":313,"sex":"1"]
//        CHSqliteManage.shareInstance().insertTable("mytab", paramDic: map)

        CHFMDB.shareInstance().insertTable("fmdbtab", paramDic: map)
    }
    
    
    @IBAction func query(_ sender: UIButton) {
        print("query")
        
        let arr:Array? =  CHFMDB.shareInstance().queryAll("fmdbtab")
        print(arr)
        
    }
    
    
    @IBAction func queryifBtn(_ sender: UIButton) {
        let SQL:String = "SELECT * FROM fmdbtab where name = 'zs'"
        let array:[Any]? = CHFMDB.shareInstance().queryConditionSql(SQL)

        print("arrar----",array)
    }
    @IBAction func updateBtn(_ sender: UIButton) {
        let SQL:String = "delete from fmdbtab  where id = 2"
        CHFMDB.shareInstance().deleteSql(SQL)
    }
    
    
    
    @IBAction func deleteBtn(_ sender: UIButton) {
        print("delete")
    }
    
    
   
    
    
    
}


